public class Demo7 {
    public static void main(String[] args) throws InterruptedException {
        Thread t =new Thread(()->{
            Thread currentThread =Thread.currentThread();
            while(!currentThread.isInterrupted()){
                System.out.println("thread");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
//                    throw new RuntimeException(e);
                    System.out.println("执行到catch操作");
                    break;//return;
                }
            }
        });

        t.start();
        Thread.sleep(3000);
        //在主线程中 控制t线程被终止,设置上述标志位
        t.interrupt();
    }
}
